<template>
    <div>
        <el-card class="box-card">
            <div slot="header" class="clearfix">
                <div>
                    <el-form ref="form" :model="form" label-width="80px">
                        <el-form-item label="服务状态">
                            <el-select v-model="form.serviceStatus" placeholder="请选择是否服务状态">
                                <el-option label="待服务" value="1"></el-option>
                                <el-option label="已服务" value="2"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-form>
                </div>
                <div>
                    <el-button type="primary" @click="init(currentPag)" icon="el-icon-search">搜索</el-button>
                    <el-button type="info" @click="refresh" icon="el-icon-refresh-right">重置</el-button>
                </div>
            </div>
            <div class="text item">
                <el-table :data="dealList" border style="width: 100%;" ref="multipleTable" v-loading="loading">
                    <el-table-column type="selection" width="55">
                    </el-table-column>
                    <el-table-column prop="id" label="ID" width="180">
                    </el-table-column>
                    <el-table-column prop="username" label="账号" width="150">
                    </el-table-column>
                    <el-table-column prop="name" label="昵称" width="150">
                    </el-table-column>
                    <el-table-column prop="phone" label="联系方式" width="120">
                    </el-table-column>
                    <el-table-column prop="address" label="地址" width="350">
                    </el-table-column>
                    <el-table-column prop="note" label="备注" width="200">
                    </el-table-column>
                    <el-table-column prop="serviceName" label="服务名称" width="150">
                    </el-table-column>
                    <el-table-column prop="homeServiceFee" label="上门费用" width="100">
                    </el-table-column>
                    <el-table-column prop="operatingFee" label="服务费用" width="100">
                    </el-table-column>
                    <el-table-column prop="totalFee" label="总费用" width="100">
                    </el-table-column>
                    <el-table-column prop="arriveTime" label="预计上门时间" width="180">
                    </el-table-column>
                    <el-table-column prop="serviceTime" label="服务时长（小时）" width="150">
                    </el-table-column>
                    <el-table-column prop="status" label="状态" width="80">
                        <template slot-scope="scope">
                            <el-tag type="success" v-show="scope.row.status == 1">正常</el-tag>
                            <el-tag type="danger" v-show="scope.row.status == 2">禁用</el-tag>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
            <div class="pagination">
                <el-pagination background layout="prev, pager, next" :total="totalPage" :page-size="pageSize"
                    @current-change="currentChange">
                </el-pagination>
            </div>
        </el-card>
    </div>
</template>

<script>
export default {
    name: "OrderDoctor",
    data() {
        return {
            // 是否加载
            loading: false,
            // 多选数据
            multipleSelection: [],
            // 当前页数
            currentPag: 1,
            // 每页大小
            pageSize: 10,
            // 总页数
            totalPage: 0,
            // 表单
            form: {
                username: "",
                serviceStatus: null
            }
        }
    },
    mounted() {
        this.init(this.currentPag)
    },
    methods: {
        async init(currentPag) {
            this.loading = true
            let res = await this.$store.dispatch("getDealDoctorList", {
                currentPag: currentPag,
                pageSize: this.pageSize,
                serviceStatus: this.form.serviceStatus
            })
            if (res.success) {
                this.totalPage = parseInt(res.data.totalPag)
                this.currentPag = parseInt(res.data.currentPag)
                this.pageSize = parseInt(res.data.pageSize)
                this.loading = false
            }
            else this.$myfun.resError(res)
        },
        // 更换页数
        currentChange(pag) {
            this.init(pag)
        },
        // 重置
        refresh() {
            let newObj = {}
            this.form = newObj
        }
    },
    computed: {
        dealList() {
            return this.$store.state.deal.dealList
        }
    }
}
</script>

<style scoped>
.clearfix {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pagination {
    padding: 20px 0 10px 0;
    text-align: center;
}

.btn {
    margin: 5px 0 5px 0;
}
</style>